﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Krist_em_up.Interface.Gui;
using Krist_em_up.Characters;
using Microsoft.Xna.Framework;

namespace Krist_em_up.Interface
{
    public class GUI
    {
        protected Viewport[] viewports;

        protected PlayerGui[] GUIs;

        protected GameStateManager game;

        protected SpriteBatch spriteBatch;

        public GUI(Kristemup k)
        {
            viewports = new Viewport[k.tabKris.Length];
            GUIs = new PlayerGui[k.tabKris.Length];

            game = k.game;

            SpriteFont font = k.Content.Load<SpriteFont>("Fonts/Gamefont2");
            font.Spacing = -10;

            for (int i = 0; i < GUIs.Length; i++)
            {
                viewports[i] = new Viewport();
                viewports[i].Height = k.defaultViewPort.Height / 5;
                viewports[i].Width = k.defaultViewPort.Width / GUIs.Length;
                viewports[i].Y = k.gameViewport.Height;
                viewports[i].X = i * viewports[i].Width + i;

                GUIs[i] = new PlayerGui(k.tabKris[i], k, font);
            }

            spriteBatch = new SpriteBatch(game.GraphicsDevice);
        }

        public void Draw()
        {
            for (int i = 0; i < GUIs.Length; i++)
            {
                game.GraphicsDevice.Viewport = viewports[i];
                GUIs[i].Draw(spriteBatch);
            }
        }
    }
}
